package com.example.behaviorpattern.mediator.impl;

import com.example.behaviorpattern.mediator.Colleague;
import com.example.behaviorpattern.mediator.Mediator;
import lombok.Getter;
import lombok.Setter;

/**
 * 具体的中介者
 *
 * @author yaojianfeng
 */
@Getter
@Setter
public class ConcreteMediator implements Mediator {
    private ConcreteColleagueA colleague1;
    private ConcreteColleagueB colleague2;

    @Override
    public void send(String message, Colleague colleague) {
        if (colleague.equals(colleague1)) {
            colleague2.receive(message);
        } else {
            colleague1.receive(message);
        }
    }
}